<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<div class="doclist">

<div class="tableTitle">项目立项管理</div>
<table class="listTable cssrain">
	<thead>
		<tr>
			<th colspan="2">
				<input type="button" id="newDoc" value="新增"/>
				<input type="button" id="delDocs" value="删除" disabled="disabled"/>
			</th>
			<th colspan="7">
				<input type="text" size="40"/>
				<input type="button" value="查询"/>
				<input type="button" value="高级查询"/>
			</th>
		</tr>
		<tr>
			<th><input id="checkboxAll" type="checkbox"/></th>
			<th>项目编号</th>
			<th>项目名称</th>
			<th>建设单位</th>
			<th>投资规模（万元）</th>
			<th>用地地点</th>
			<th>用地面积（平方米）</th>
			<th>立项时间</th>
			<th>立项批准文号</th>
			
		</tr>
	</thead>
	<tbody></tbody>
</table>
<div class="pages">
	<div class="pagesL">&nbsp;&nbsp;&nbsp;&nbsp;共<strong id="total"> 180</strong> 条记录&nbsp;&nbsp;<strong> 15</strong> 条/页，当前第<strong> 1</strong> 页</div>
	<div class="pagesC">◀◀上一页&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;2&nbsp;3&nbsp;4&nbsp;5&nbsp;...&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;下一页▶▶</div>
	<div class="pagesR">转到&nbsp; <input type="text" style="width:25px; height:12px; font-size:12px; border:solid 1px #7aaebd;"/>&nbsp;&nbsp;页&nbsp;&nbsp;&nbsp;</div>
</div>

<script type="text/javascript">
	// For Demo
	tbodyHtml = "";
	var doc;
	var today = new Date();
	var count = 0;
	for (var id in window.memDocs) {
		if (count < 15) {		
			doc = window.memDocs[id];
			if (!doc)
				continue;
			
			tbodyHtml += "<tr><td><input type='checkbox' class='recSelect' value='"+id+"'/>"
				+"</td><td>"+doc.id
				+"</td><td>"+doc.projName
				+"</td><td>"+doc.projOrg
				+"</td><td>"+doc.investScale
				+"</td><td>"+doc.projAddr
				+"</td><td>"+doc.projArea
				+"</td><td>"+doc.setupDate.toStdDateString()
				+"</td><td>"+doc.approveNum
				+"</td></tr>";

		}
		count++;
	}

	for (;count < 15; count++) {
		tbodyHtml += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
	}
	
	$(".listTable > tbody").html(tbodyHtml);
	$(".pages > .pagesL > #total").html(count);
	
</script>
<script type="text/javascript" src="<%=basePath %>admin/js/table-chexkbox.js"></script>
<script type="text/javascript">

	$('.cssrain tbody').delegate("tr", "click", function() {
		if ($('.cssrain input[type="checkbox"]:checked').length > 0) {
			$("#delDocs").removeAttr("disabled");
		} else { 
			$("#delDocs").attr("disabled", "disabled");
		}
	});

	$('.cssrain tbody').delegate("tr", "dblclick", function(evt) {
		var prid = $(this).find('input[type="checkbox"]').val();

		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/projView.jsp?prid="+prid,
			title:	'查看项目信息',
			buttons:{'取消':function(){closeDialog();}}
		});
	});
	
	$("#newDoc").click(function() {
		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/projSetup.jsp",
			title:	'工程建设项目立项登记',
			buttons:{'取消':function(){closeDialog();},'保存':function(){closeDialog();sucTip();}}
		});
	});

	$("#delDocs").click(function() {
		if (!confirm("确定要删除所选文档吗？"))
			return false;

		$('.cssrain input[type="checkbox"]:checked').each(function(index, elem) {
			var id = $(elem).val();
			window.memDocs[id] = undefined;
		});
		
		$.simpleTip("成功删除");
		$("#manager").load("<%=basePath%>admin/attendInstList.jsp");
	});

	$(".editDoc").click(function(evt){
		var did = $(this).parents("tr").find('input[type="checkbox"]').val();
		
		$().simpleDialog({
			ajax:true,
			ajaxUrl:	"<%=basePath%>admin/attendInstEdit.jsp?did="+did,
			title:	'编辑文档信息',
			buttons:{'取消':function(){closeDialog();},'保存':function(){closeDialog();sucTip();}}
		});
	});
</script>
</div>